package com.fxb.project.exam;

public class Test31 implements Runnable{
    private int task = 5;
    @Override
    public void run() {
        while(task>0){
            try {
                Thread.sleep(30);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            synchronized (this){
                System.out.println(Thread.currentThread().getName()+":完成第"+(task--)+"项任务");
            }
        }

    }

    public static void main(String[] args) {

        Test31 actor = new Test31();
        new Thread(actor,"Actor").start();
        new Thread(actor,"Actor").start();
    }
}
